package com.gsafety.library

import android.app.Application
import android.content.Context
import com.gsafety.library.integration.AppDelegate
import com.tencent.mmkv.MMKV
import autolayoutlib.config.AutoLayoutConifg

/**
 * @author : lj
 * @date : 2020/9/16 16:35
 */
class BaseApplication : Application() {
    private var mAppDelegate: AppDelegate? = null
    override fun onCreate() {
        super.onCreate()
        instance = this
        mAppDelegate!!.onCreate(this)
        val rootDir = MMKV.initialize(this)
        AutoLayoutConifg.getInstance().init(this, 1080, 1920)
    }

    override fun attachBaseContext(base: Context) {
        super.attachBaseContext(base)
        if (mAppDelegate == null) {
            mAppDelegate = AppDelegate(base)
        }
        mAppDelegate!!.attachBaseContext(base)
    }

    fun getmAppDelegate(): AppDelegate? {
        return mAppDelegate
    }

    companion object {
        var instance: BaseApplication? = null
            private set
    }
}